package com.wn.production.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wn.common.PageBean;
import com.wn.entity.BorrowerMeasuringDevice;
import com.wn.production.mapper.BorrowerMeasuringDeviceMapper;
import com.wn.production.service.BorrowerMeasuringDeviceService;
import com.wn.production.vo.BorrowerMeasuringDeviceVo;
import com.wn.utils.CurrentTime;
import com.wn.utils.PageBeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BorrowerMeasuringDeviceMapperImpl implements BorrowerMeasuringDeviceService {
    @Autowired
    private BorrowerMeasuringDeviceMapper borrowerMeasuringDeviceMapper;
    @Override
    public void insert(BorrowerMeasuringDevice borrowerMeasuringDevice) {
        String number="JY"+ CurrentTime.getCurrentTimeString();
        borrowerMeasuringDevice.setNumber(number);
        borrowerMeasuringDeviceMapper.insert(borrowerMeasuringDevice);
    }

    @Override
    public PageBean<BorrowerMeasuringDevice> getByCondition(BorrowerMeasuringDeviceVo borrowerMeasuringDeviceVo) {
        Page<BorrowerMeasuringDevice> page = PageHelper.startPage(borrowerMeasuringDeviceVo.getCurrPage(), borrowerMeasuringDeviceVo.getPageSize());
        List<BorrowerMeasuringDevice> list = borrowerMeasuringDeviceMapper.getByCondition(borrowerMeasuringDeviceVo.getBorrowerMeasuringDevice());
        return PageBeanUtil.getPageBean(list,page,borrowerMeasuringDeviceVo.getCurrPage(),borrowerMeasuringDeviceVo.getPageSize());
    }

    @Override
    public void update(BorrowerMeasuringDevice borrowerMeasuringDevice) {
        borrowerMeasuringDeviceMapper.update(borrowerMeasuringDevice);
    }
}
